package com.kbtd.service.handle;

import com.kbtd.service.mq.VoucherOrderBlockConsumer;
import com.kbtd.service.mq.VoucherOrderRedisConsumer;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author wp
 * @data 2024/9/18
 */
@Component
public class VoucherOrderHandle {
    @Resource
    private VoucherOrderRedisConsumer voucherOrderRedisConsumer;
    @Resource
    private VoucherOrderBlockConsumer voucherOrderBlockConsumer;

    private static final ExecutorService SECKILL_ORDER_EXECUTOR = Executors.newSingleThreadExecutor();


    @PostConstruct
    public void handle() {
        handleV2();
    }

    public void handleV2() {
        SECKILL_ORDER_EXECUTOR.submit(voucherOrderRedisConsumer);
    }

    public void handleV1() {
        SECKILL_ORDER_EXECUTOR.submit(voucherOrderBlockConsumer);
    }
}
